package com.mbti.youmore.controller;



import com.mbti.youmore.entity.resp.ResponseData;
import com.mbti.youmore.service.PersonalityService;
import com.mbti.youmore.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



/**
 * 用户模块控制器
 * @version 1.0
 * @since 1.0
 */
@RestController
@RequestMapping("/personality") // 配置类路径
public class PersonalityController {

    @Autowired
    private PersonalityService personalityService;


    @RequestMapping(path = "/getrole/{id}", method = RequestMethod.GET) // 配置方法路径
    public ResponseData selectByroleId(@PathVariable("id") Integer id) {
        String  result = null;
        result =personalityService.selectByroleId(id);
        if (result != null) {
            return ResponseUtil.getSuccessResponse(result);
        } else {
            return ResponseUtil.getResponseData(401);
        }
    }

    @RequestMapping(path = "/getexplaining/{id}", method = RequestMethod.GET) // 配置方法路径
    public ResponseData selectBypersonality(@PathVariable("id") Integer id) {
        String  result = null;
        result =personalityService.selectBypersonality(id);
        if (result != null) {
            return ResponseUtil.getSuccessResponse(result);
        } else {
            return ResponseUtil.getResponseData(401);
        }
    }

    @RequestMapping(path = "/getpersonality/{personality}", method = RequestMethod.GET) // 配置方法路径
    public ResponseData selectIdBypersonality(@PathVariable("personality") String personality) {
        int   result = -1;
        result =personalityService.selectIdBypersonality(personality);
        if (result != -1) {
            return ResponseUtil.getSuccessResponse(result);
        } else {
            return ResponseUtil.getResponseData(401);
        }
    }

    @RequestMapping(path = "/getmbtipic/{id}", method = RequestMethod.GET) // 配置方法路径
    public ResponseData selectmbtiPic(@PathVariable("id") Integer id) {
        String   result = null;
        result =personalityService.selectmbtiPic(id);
        if (result != null) {
            return ResponseUtil.getSuccessResponse(result);
        } else {
            return ResponseUtil.getResponseData(401);
        }
    }
}